<?php

namespace App\Services\CallbackRequest;

use App\Services\BaseService;
use App\Services\Request\CallbackRequest;
use App\Services\ServiceTrait;
use Illuminate\Database\Eloquent\Builder;

class CallbackRequestService extends BaseService
{
    use ServiceTrait;

    /**
     * 构造函数
     */
    public function __construct()
    {
    }
    public function filter(): void
    {
        $this->query
            //创建时间
            ->when($queryValue = $this->getParam('created_time'), function (Builder $q) use ($queryValue) {
                $q->whereBetween('created_at', get_date_range($queryValue));
            });
    }

    public function send() : mixed {
        return (new CallbackRequest([
            'url' => $this->getParam('url')
        ]))->send($this->getParam('data',[]));
    }
}
